<template>
<view>
  <view
  class="item"
    v-for="item in getlists"
    :key="item.id"
  >
    <view>
      <view class="title">
        <text>
          {{item.title}}
        </text>
      </view>
      <view class="time">
        <text>发表时间:{{item.add_time | formData}}</text>
        <view class="click">
        <text>浏览次数:{{item.click}}</text>
        </view>
      </view>
      <view >
       <rich-text :nodes="item.content"></rich-text>
      </view>
    </view>
  </view>
  </view>
</template>

<script>
export default {
   filters:{
    formData(data){
      const newdata=new Date(data)
      const year=newdata.getFullYear()
      const month=newdata.getMonth()+1
      const dat =newdata.getDay()
      const hour =newdata.getHours()
      const min=newdata.getMinutes()
      return year+'年'+month+'月'+dat+'日'+hour+'时'+min+'分'
    }
  },
  data() {
    return {
      id: null,
      getlists: [],
    };
  },
  onLoad(option) {
    console.log(option.id);
    this.id = option.id;
    this.getlist();
  },
  methods: {
    getlist() {
      uni.request({
        url: "http://localhost:8082/api/getnew/" + this.id,
        success: (res) => {
          console.log(res.data.message);
          this.getlists = res.data.message;
        },
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.item{
.title{
  text-align: center;
  font-size: 33rpx;
}
.time{
  display:flex;
  font-size: 28rpx;
  margin: 30rpx 0 30rpx 20rpx;
  .click{
    margin-left: 200rpx;
  }
}
}

</style>
